package com.wtwd.campus.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.wtwd.campus.dao.PolygonFenceMapper;
import com.wtwd.campus.entity.PolygonFence;
import com.wtwd.campus.service.PolygonFenceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mjy
 * @since 2022-11-08
 */
@Service
public class PolygonFenceServiceImpl implements PolygonFenceService {

    @Resource
    private PolygonFenceMapper polygonFenceMapper;


    @Override
    public PolygonFence getOrgPolygonFenceByDeviceTypeAndCustomerIdAndFenceId(int deviceType, int customerId, String fenceId) {
        return new LambdaQueryChainWrapper<>(polygonFenceMapper)
                .eq(PolygonFence::getDeviceType, deviceType)
                .eq(PolygonFence::getCustomerId, customerId)
                .eq(PolygonFence::getFenceId, fenceId)
                .one();
    }

    @Override
    public Integer save(PolygonFence polygonFence) {
        return polygonFenceMapper.insert(polygonFence);
    }

    @Override
    public Integer update(PolygonFence polygonFence) {
        return polygonFenceMapper.updateById(polygonFence);
    }

    @Override
    public Integer deleteById(Integer id) {
        return polygonFenceMapper.deleteById(id);
    }

}
